home *** CD-ROM | disk | FTP | other *** search
/ MACup: Giveaway 1996 / Image.iso / Shareware & Demos / Web-Publishing / SNAP PrimeBase / PrimeBase™ Server PPC / Setup / Scripts / config.dal < prev    next >
Encoding:
Text File  |  1996-07-13  |  21.1 KB  |  632 lines  |  [TEXT/ds30]

  1. /*
  2.     P.INK SQL DataServer configuration
  3.     --------------------------------------
  4.  
  5.     Procedure    CONFIG
  6.  
  7.     This procedure calculates values for system variables
  8.     for 'good performance operation' of a DataServer.
  9.     There are several input parameters for configuration
  10.     which will be described when the procedure is called
  11.     from a console like this:
  12.     config(1);
  13.  
  14.     If you just want to have a look at some examples:
  15.     config(2);
  16.     
  17.     For credits:
  18.     config(6);
  19.  
  20.     P.INK Hamburg, October 1993 (updated September 1995)
  21.  
  22. */
  23.  
  24. declare procedure config(CheckTotalMemory, NumberOfSessions, System, SetVar)
  25. argument int CheckTotalMemory = 0;
  26. argument int NumberOfSessions = 0;
  27. argument int System = 0;
  28. argument char SetVar = "NO";
  29. {
  30.     int        StaticMemory = 1536;
  31.     int        MaxStaticMemory = 3074;
  32.     int        ServerFrontEnd;
  33.     int        LogBufferSize = 2 * 32;
  34.     int        InitialMemoryBlock, Sessions, SessionSize = 256;
  35.     int        TotalMemory, RestMemory, CacheMemory, ConnectionMemory, BlockSize, BlockCount, UsedMemory;
  36.     int        SystemFiles, TransactionLimit;
  37.     int        cVersion = integer($substr($right($version, '#'), 1, 4));
  38.  
  39.     int        is_open = 0;
  40.     varchar    dname = "<unknown>";
  41.     varchar cSystem;
  42.  
  43.     print "";
  44.  
  45.     if(CheckTotalMemory != 5)
  46.     {
  47.         print $format("\tP.INK SQL DataServer configuration");
  48.         print $format("\t--------------------------------------");
  49.     }
  50.  
  51.     if(CheckTotalMemory < 0 or NumberOfSessions < 0 or (CheckTotalMemory > 6 and CheckTotalMemory < 2048))
  52.     {
  53.         print $format("\tInvalid input parameter !");
  54.         CheckTotalMemory = 1;
  55.         print "";
  56.     }
  57.  
  58.     SetVar = $toupper(SetVar);
  59.     if(System < 0 or System > 2)
  60.         System = 0;
  61.  
  62.     if(CheckTotalMemory = 1)
  63.     {
  64.         print $format("\tThis procedure CONFIG calculates a configuration that");
  65.         print $format("\tshould give 'good performance' in common environments.");
  66.         print "";
  67.         print $format("\tFor good performance the memory that is available to the server");
  68.         print $format("\tis reduced by the amount of static memory and then split to 1/3");
  69.         print $format("\tfor Session memory and 2/3 for Cache and Virtual Cache memory.");
  70.         print $format("\tIf there is not enough memory available, the required size per session");
  71.         print $format("\tis reduced from 256 KB to 128 KB. If there is still not enough memory");
  72.         print $format("\tavailable the required size for the Cache and Virtual Cache is reduced");
  73.         print $format("\tdown to a limit of 512 KB. If there is still not enough memory the");
  74.         print $format("\tlast thing to do is to reduce the number of sessions.");
  75.         print "";
  76.         print $format('\tCall the procedure like this:');
  77.         print $format('\tCONFIG(Memory, Sessions, System, "Set");');
  78.         print "";
  79.         print $format("\tMemory  : 0 or empty calculates required memory for the current server.");
  80.         print $format("\t          1  shows this information.");
  81.         print $format('\t          2  shows examples of how to call this procedure.');
  82.         print $format('\t          3  shows the current values of the system variables on current Server.');
  83.         print $format('\t          4  same as 3 plus other system variables and system formats.');
  84.         print $format("\t          Any number greater than 2048 is the considered to be the number");
  85.         print $format("\t          of KB of memory you want to give to the DataServer.");
  86.         print "";
  87.         print $format("\tSessions: Number of Sessions you want to give to the DataServer.");
  88.         print $format("\t          0 or empty caluclates with the value of ConnectionLimit.");
  89.         print "";
  90.         print $format('\tSystem  : 1 calculation is for a Macintosh server.');
  91.         print $format('\t          2 calculation is for a Unix server.');
  92.         print $format("\t          0 or empty calculates for the current server.");
  93.         print "";
  94.         print $format('\tSet     : "save" if you are satisfied with the calculated values and');
  95.         print $format("\t          you want the procedure to save them on the DataServer.");
  96.         print $format('\t          "show" preceeds the calculated values with SET VARIABLE');
  97.         print $format("\t          so they can be used with copy/paste to save them 'by hand'.");
  98.         print "";
  99.         print $format('\tCall CONFIG(1) for this information or CONFIG(2) for examples.');
  100.         print "";
  101.         return; 
  102.     }
  103.     if(CheckTotalMemory = 2)
  104.     {
  105.         print $format("\tExamples:");
  106.         print $format("\tconfig(1);");
  107.         print $format("\tShow help information about this procedure.");
  108.         print "";
  109.         print $format("\tconfig(3);");
  110.         print $format('\tShow the current values of the system variables on current Server.');
  111.         print "";
  112.         print $format('\tconfig(4,,,"show"); OR setting;');
  113.         print $format('\tShow current values of the system variables and formats with SET VARIABLE.');
  114.         print "";
  115.         print $format("\tconfig; or config(0,0,0,0);");
  116.         print $format("\tCalculate required memory for current Server with current sessions.");
  117.         print "";
  118.         print $format('\tconfig(16*1024, ,2);');
  119.         print $format('\tShow values for a Unix Server with current sessions and 16 MB.');
  120.         print "";
  121.         print $format('\tconfig(5*1024, 10, 1);');
  122.         print $format('\tShow values for a Mac Server with 5 MB and 20 sessions.');
  123.         print "";
  124.         print $format('\tconfig(,10,, "save");');
  125.         print $format('\tCalculate required memory for 10 sessions on current Server and save values.');
  126.         print "";
  127.         print $format('\tconfig(4500, 10, 1, "show");');
  128.         print $format('\tShow values with SET VARIABLE for a Mac Server with 4500 KB and 10 sessions.');
  129.         print "";
  130.         return; 
  131.     }
  132.  
  133.     if(CheckTotalMemory = 6)
  134.     {
  135.         print $format("\tThis procedure 'CONFIG' (version 1.6) was brought to you by:");
  136.         print "";
  137.         print $format("\tDAL programming:\tDieko Jacobi");
  138.         print $format("\tMemory manager :\tPaul McCullagh");
  139.         print $format("\tSpecial thanks :\tMitch Frazer, Dirk Strack, Ingo Karge, Barry Leslie");
  140.         print "";
  141.         print $format("\tP.INK software engineering GmbH & Co.");
  142.         print $format("\tRothenbaumchaussee 5");
  143.         print $format("\t20148 Hamburg");
  144.         print $format("\tGermany");
  145.         print "";
  146.         print $format("\tFor further information call: ++49 - 40 - 411 709 0");
  147.         print $format("\t                         Fax: ++49 - 40 - 411 709 10");
  148.         print $format("\t                    Internet: support.sql@pink.de");
  149.         print $format("\t                  Apple Link: Ger.XSE0006");
  150.         print "";
  151.         print "";
  152.         print "";
  153.         return; 
  154.     }
  155.  
  156.     describe open databases into db;
  157.     for each db
  158.     {
  159.         if(db->alias = "mem_set")
  160.         {
  161.             is_open = 1;
  162.             use database mem_set;
  163.             break;
  164.         }
  165.     }
  166.  
  167.     if(is_open=0)
  168.     {
  169.         errorctl ,1;
  170.         open database master alias mem_set;
  171.         errorctl ,0;
  172.  
  173.         describe open databases into db;
  174.         for each db
  175.         {
  176.             if(db->alias = "mem_set")
  177.             {
  178.                 is_open = 1;
  179.                 break;
  180.             }
  181.         }
  182.     }
  183.     
  184.     if(CheckTotalMemory = 3 or CheckTotalMemory = 4 or CheckTotalMemory = 5)
  185.     {
  186.         if(is_open=0)
  187.         {
  188.             print $format("\tThe Master database is not open so the values");
  189.             print $format("\tof the system variables can not be looked up.");
  190.             print $format("\tYou need SA privilege to open the Master database.");
  191.             print "";
  192.             return;
  193.         }
  194.         /* DataServerName */
  195.         select    value
  196.         from    sysvariables
  197.         where    id = (select id from SysObjects where Name = "DataServerName")
  198.         into tmp for extract;
  199.         fetch first of tmp;
  200.         dname = tmp->value;
  201.         print $format("\tCurrent values of the system variables on DataServer '%s':", dname);
  202.  
  203.         select        B.Name, int A.Value as Value, A.DBID
  204.         from        mem_set!System.SysVariables    as A,
  205.                     mem_set!System.SysObjects    as B
  206.         where        A.DBID                 /= B.DBID
  207.         and            A.DataType            == $integer
  208.         and            A.VariableType        == 'Par'
  209.         order by    A.DBID
  210.         into        vars;
  211.         for each vars
  212.         {
  213.             if (not ($locate(vars->Name, "Memory") > 0 and vars->Value is null))
  214.             {
  215.                 if(SetVar = "SHOW")
  216.                         print $format("\tSET VARIABLE %-25s = %d;", vars->Name, vars->Value);
  217.                 else
  218.                 {
  219.                     if(vars->Value > 1024)
  220.                         print $format("\t%-25s = %-10s (%d KB)", vars->Name, vars->Value, vars->Value / 1024);
  221.                     else
  222.                         print $format("\t%-25s = %d", vars->Name, vars->Value);
  223.                 }
  224.             }
  225.         }
  226.  
  227.         if(CheckTotalMemory = 3)
  228.         {
  229.             print "";
  230.             print $format('\tTry also:');
  231.             print $format('\tCONFIG(4,,,"show");');
  232.             print $format('\tor');
  233.             print $format('\tSETTING;');
  234.         }
  235.         
  236.         if(CheckTotalMemory = 4)
  237.         {
  238.             select        B.Name, varchar A.Value as Value, A.DBID
  239.             from        mem_set!System.SysVariables    as A,
  240.                         mem_set!System.SysObjects    as B
  241.             where        A.DBID                 /= B.DBID
  242.             and            A.DataType            == $varchar
  243.             and            A.VariableType        == 'Par'
  244.             order by    A.DBID
  245.             into        vars;
  246.             for each vars
  247.             {
  248.                 if(SetVar = "SHOW")
  249.                     print $format("\tSET VARIABLE %-25s = '%s';", vars->Name, vars->Value);
  250.                 else
  251.                     print $format("\t%-25s = %s", vars->Name, vars->Value);
  252.             }
  253.             print "";
  254.             if(SetVar = "SHOW")
  255.             {
  256.                 print $format("\tLimits:");
  257.                 print $format("\tSET $maxrows     = %d;", $maxrows);
  258.                 print $format("\tSET $rowsperpage = %d;", $rowsperpage);
  259.                 print $format("\tSET $locktimeout = %d;", $locktimeout);
  260.                 print "";
  261.  
  262.                 print $format("\tFormats:");
  263.                 print $format('\tSET $decfmt      = "%s";', $decfmt);
  264.                 print $format('\tSET $moneyfmt    = "%s";', $moneyfmt);
  265.                 print $format('\tSET $tsfmt       = "%s";', $tsfmt);
  266.                 print $format('\tSET $datefmt     = "%s";', $datefmt);
  267.                 print $format('\tSET $timefmt     = "%s";', $timefmt);
  268.                 print $format('\tSET $month       = "%s";', $month);
  269.                 print $format('\tSET $day         = "%s";', $day);
  270.                 print $format('\tSET $ampm        = "%s";', $ampm);
  271.                 print "";
  272.                 describe open dbms into vars;
  273.                 fetch of vars;
  274.                 print $format('\tYou are logged in as user "' + $user + '" using brand "' + vars->brand + '" version "' + vars->rev + '"');
  275.             }
  276.             else
  277.             {
  278.                 print $format("\tLimits:");
  279.                 print $format("\t$maxrows     = %d", $maxrows);
  280.                 print $format("\t$rowsperpage = %d", $rowsperpage);
  281.                 print $format("\t$locktimeout = %d", $locktimeout);
  282.                 print "";
  283.  
  284.                 print $format("\tFormats:");
  285.                 print $format('\t$decfmt      = %s', $decfmt);
  286.                 print $format('\t$moneyfmt    = %s', $moneyfmt);
  287.                 print $format('\t$tsfmt       = %s', $tsfmt);
  288.                 print $format('\t$datefmt     = %s', $datefmt);
  289.                 print $format('\t$timefmt     = %s', $timefmt);
  290.                 print $format('\t$month       = %s', $month);
  291.                 print $format('\t$day         = %s', $day);
  292.                 print $format('\t$ampm        = %s', $ampm);
  293.                 print "";
  294.                 print $format('\tTry also:');
  295.                 print $format('\tCONFIG(4,,,"show");');
  296.                 print $format('\tor');
  297.                 print $format('\tSETTING;');
  298.             }
  299.         }
  300.         print "";
  301.         return;
  302.     }
  303.  
  304.     if(System = 0)
  305.     {
  306.         if(is_open=0)
  307.         {
  308.             print $format("\tYou did not specify the system on what the DataServer is running");
  309.             print $format("\tand the Master database is not open so it can not be looked up.");
  310.             print $format('\tYou need SA privilege to open the Master database or call config(1);');
  311.             print $format("\tfor further descriptions.");
  312.             print "";
  313.             return;
  314.         }
  315.         /* Get the SerialNumber */
  316.         select    value
  317.         from    sysvariables
  318.         where    id = (select id from SysObjects where Name = "SerialNumber")
  319.         into tmp for extract;
  320.         fetch first of tmp;
  321.         
  322.         /* The second digit contains version information: M = Mac, S/I = Unix, A = Any (ask) */
  323.         if($substr(tmp->value,2,1) = "M")
  324.             System = 1;
  325.         if($substr(tmp->value,2,1) = "S" or $substr(tmp->value,2,1) = "I")
  326.             System = 2;
  327.         
  328.     }
  329.  
  330.     if(System = 2)
  331.     {
  332.         cSystem            = "Unix";
  333.         ServerFrontEnd    = 0;
  334.         BlockSize        = 1024;
  335.         SystemFiles        = 50;
  336.     }
  337.     else
  338.     {
  339.         if(System != 1)    
  340.         {
  341.             print $format("\tThe system on what the DataServer is running can not be identified.");
  342.             print $format('\tIf running on a Mac the 3. paramter has to be 1 on Unix 2');
  343.             print $format('\tFor now the calculation will be continued for a Macintosh.');
  344.             print $format('\tType: config(1); if you need more information about this procedure.');
  345.             print $format('\tType: config(2); if you need examples of how to call this procedure.');
  346.             print "";
  347.         }
  348.         cSystem            = "Macintosh";
  349.         ServerFrontEnd    = 850;
  350.         BlockSize        = 512;
  351.         SystemFiles        = 240;
  352.     }
  353.  
  354.     if(is_open=1)
  355.     {
  356.         /* DataServerName */
  357.         select    value
  358.         from    sysvariables
  359.         where    id = (select id from SysObjects where Name = "DataServerName")
  360.         into tmp for extract;
  361.         fetch first of tmp;
  362.         dname = tmp->value;
  363.  
  364.         /* LogBufferSize */
  365.         select    value
  366.         from    sysvariables
  367.         where    id = (select id from SysObjects where Name = "LogBufferSize")
  368.         into tmp for extract;
  369.         fetch first of tmp;
  370.         LogBufferSize = 2 * (tmp->value / 1024);
  371.     }
  372.  
  373.     StaticMemory = StaticMemory + LogBufferSize;
  374.     if(StaticMemory > MaxStaticMemory)
  375.         StaticMemory = MaxStaticMemory;
  376.  
  377.     if(is_open=1)
  378.         print $format("\tTunings for the DataServer '%s' (%s)", dname, cSystem);
  379.     else
  380.         print $format("\tTunings for a DataServer running on %s", cSystem);
  381.  
  382.     print "";
  383.     if(NumberOfSessions = 0)
  384.     {
  385.         if(is_open=0)
  386.         {
  387.             print $format("\tYou did not specify the number of sessions and");
  388.             print $format("\tthe Master database is not open so it can not be looked up.");
  389.             print $format("\tYou need SA privilege to open the Master database.");
  390.             print $format("\tThe calculation will be based on the default value of 5 sessions.");
  391.             print "";
  392.             Sessions = 5;
  393.         }
  394.         else
  395.         {
  396.             /* ConnectionLimit */
  397.             select    value
  398.             from    sysvariables
  399.             where    id = (select id from SysObjects where Name = "ConnectionLimit")
  400.             into tmp for extract;
  401.             fetch first of tmp;
  402.             Sessions = tmp->value;
  403.         }
  404.     }
  405.     else
  406.         Sessions = NumberOfSessions;
  407.     
  408.     ConnectionMemory    = Sessions * SessionSize;
  409.     CacheMemory            = 2 * ConnectionMemory;
  410.     TotalMemory            = StaticMemory + ServerFrontEnd + CacheMemory + ConnectionMemory;
  411.  
  412.     print $format("\tGood performance with %d sessions requires %d KB of memory.", Sessions, TotalMemory);
  413.  
  414.     if(CheckTotalMemory > 0)
  415.     {
  416.         print $format("\tYou specified %d KB of memory for the calculation.", CheckTotalMemory);
  417.         if(CheckTotalMemory = TotalMemory)
  418.             print $format("\tThat is just right", CheckTotalMemory);
  419.         else
  420.         {
  421.             print $format("\tGood performance with %d KB of memory supports %d sessions", CheckTotalMemory, ((CheckTotalMemory - ServerFrontEnd - StaticMemory) / 3) / SessionSize);
  422.             while(TotalMemory > CheckTotalMemory and SessionSize > 128)
  423.             {
  424.                 SessionSize = SessionSize -64;
  425.                 print $format('\tNot enough memory for %d KB per session, size reduced to %d KB', SessionSize +64, SessionSize);
  426.                 ConnectionMemory    = Sessions * SessionSize;
  427.                 CacheMemory            = 2 * ConnectionMemory;
  428.                 TotalMemory            = StaticMemory + ServerFrontEnd + CacheMemory + ConnectionMemory;
  429.             }
  430.  
  431.             if(TotalMemory < CheckTotalMemory)
  432.             {
  433.                 print $format("\tThere are %d KB more than required which will be added to the Cache memory.", CheckTotalMemory - TotalMemory);
  434.                 CacheMemory = CacheMemory + (CheckTotalMemory - TotalMemory);
  435.                 TotalMemory    = StaticMemory + ServerFrontEnd + CacheMemory + ConnectionMemory;
  436.             }
  437.             else
  438.             {
  439.                 if(TotalMemory > CheckTotalMemory)
  440.                 {
  441.                     print $format('\tNot enough memory for minimum connection size, reducing cache size');
  442.                     CacheMemory = 2 * ConnectionMemory;
  443.                     
  444.                     /* Reduce cache size in steps of 10% */
  445.                     while(ServerFrontEnd + CacheMemory + ConnectionMemory + StaticMemory > CheckTotalMemory and CacheMemory >= 512)
  446.                         CacheMemory = CacheMemory - (CacheMemory / 10);
  447.  
  448.                     if(ServerFrontEnd + CacheMemory + ConnectionMemory + StaticMemory <= CheckTotalMemory)
  449.                         CacheMemory = CacheMemory + CheckTotalMemory - (ServerFrontEnd + CacheMemory + ConnectionMemory + StaticMemory);
  450.                     TotalMemory = StaticMemory + ServerFrontEnd + CacheMemory + ConnectionMemory;
  451.                     print $format('\tCache memory is reduced to %d KB (%d%)', CacheMemory, (CacheMemory+0.0) * 100 / (TotalMemory - ServerFrontEnd - StaticMemory));
  452.                 }
  453.                 else
  454.                 {
  455.                     CacheMemory = CacheMemory + (CheckTotalMemory - TotalMemory);
  456.                     TotalMemory    = StaticMemory + ServerFrontEnd + CacheMemory + ConnectionMemory;
  457.                 }
  458.                 if(TotalMemory > CheckTotalMemory)
  459.                 {
  460.                     print $format('\tBut even this minimum configuration for %d sessions requires %d KB', Sessions, TotalMemory);
  461.                     Sessions = (2 * ((CheckTotalMemory - ServerFrontEnd - StaticMemory) / 3) / 128);
  462.                     print $format('\tThe configuration with %d KB should not have more than %d sessions', CheckTotalMemory, Sessions);
  463.                     print "";
  464.                     return; 
  465.                 }
  466.                 else
  467.                 {
  468.                     CacheMemory = CacheMemory + (CheckTotalMemory - TotalMemory);
  469.                     TotalMemory    = StaticMemory + ServerFrontEnd + CacheMemory + ConnectionMemory;
  470.                 }
  471.  
  472.                 print $format('\t%d KB supports %d sessions (%d KB) with reduced cache memory', TotalMemory, Sessions, SessionSize);
  473.                 print $format("\tThat is OK");
  474.             }
  475.         }
  476.     }
  477.     if(CacheMemory < 512)
  478.     {
  479.         print $format("\tBut: Not enough memory for Cache: Minimum is 512 KB, available are %d KB", CacheMemory);
  480.         print "";
  481.         return; 
  482.     }
  483.  
  484.     /* Take 25 % of the available memory for the InitialMemoryBlock */
  485.     InitialMemoryBlock = TotalMemory/4;
  486.  
  487.     RestMemory = TotalMemory - InitialMemoryBlock;
  488.     BlockCount = (RestMemory / BlockSize) +1;
  489.  
  490.     if( BlockCount > 40)
  491.     {
  492.         BlockCount = 40;
  493.         BlockSize = RestMemory / (BlockCount - 1);
  494.     }
  495.  
  496.     while(BlockCount < 2)
  497.     {
  498.         BlockSize = BlockSize / 2;
  499.         print $format("\tNot enough blocks (%d) available, block size reduced from %d KB to %d KB", BlockCount, BlockSize*2, BlockSize);
  500.         BlockCount = (RestMemory / BlockSize) +1;
  501.     }
  502.     UsedMemory = ((BlockCount -1) * BlockSize);
  503.  
  504.     /* Add the rest of the block memory to the InitialMemoryBlock */
  505.     InitialMemoryBlock = InitialMemoryBlock + (RestMemory - UsedMemory);
  506.  
  507.     print "";
  508.     print $format("\tThe memory is used like this:");
  509.     if(cSystem = "Macintosh")
  510.         print $format("\tDataServer frontend    \t\t=%8d KB", ServerFrontEnd);
  511.     print $format("\tStatic Memory       \t\t=%8d KB", StaticMemory);
  512.     print $format("\t%d Sessions (%d KB each)\t=%8d KB (%d\%)", Sessions, SessionSize, ConnectionMemory, (ConnectionMemory+0.0) *100 / (TotalMemory - ServerFrontEnd - StaticMemory));
  513.     print $format("\tCache Memory        \t\t=%8d KB (%d\%)", CacheMemory, (CacheMemory+0.0) *100 / (TotalMemory - ServerFrontEnd - StaticMemory));
  514.     print $format("\t                    \t\t------------");
  515.     print $format("\tTotal               \t\t=%8d KB", StaticMemory + ServerFrontEnd + CacheMemory + ConnectionMemory);
  516.  
  517.     print "";
  518.     TransactionLimit = Sessions;
  519.     if(Sessions < 32)
  520.         TransactionLimit = 31;
  521.     if(Sessions > 255)
  522.         TransactionLimit = 254;
  523.  
  524.     if(SetVar = "SAVE")
  525.         print $format("\tThe system variables will be set to the following values:");    
  526.     else
  527.         print $format("\tThe system variables should be set to the following values:");    
  528.  
  529.     if(SetVar = "SHOW")
  530.     {
  531.         print $format("\tSET VARIABLE %-25s = %d;", "TransactionLimit",    TransactionLimit + 1);
  532.         print $format("\tSET VARIABLE %-25s = %d;", "SystemFileLimit",    SystemFiles);
  533.         print $format("\tSET VARIABLE %-25s = %d;", "CacheSize",        CacheMemory/2 * 1024);
  534.         print $format("\tSET VARIABLE %-25s = %d;", "VirtualCacheSize",    CacheMemory/2 * 1024);
  535.         print $format("\tSET VARIABLE %-25s = %d;", "ConnectionLimit",    Sessions);
  536.         if (not (cSystem = "Macintosh" and cVersion >= 2400))
  537.          {
  538.             print $format("\tSET VARIABLE %-25s = %d;", "InitialMemoryBlockSize",    InitialMemoryBlock * 1024);
  539.             print $format("\tSET VARIABLE %-25s = %d;", "MemoryBlockSize",    BlockSize * 1024);
  540.             print $format("\tSET VARIABLE %-25s = %d;", "MemoryBlockTotal",    BlockCount);
  541.         }
  542.         config(5,,,"show");
  543.     }
  544.     else
  545.     {
  546.         print $format("\tTransactionLimit          = %d", TransactionLimit + 1);
  547.         print $format("\tSystemFileLimit           = %d", SystemFiles);
  548.         print $format("\tCacheSize                 = %d", CacheMemory/2 * 1024);
  549.         print $format("\tVirtualCacheSize          = %d", CacheMemory/2 * 1024);
  550.         print $format("\tConnectionLimit           = %d", Sessions);
  551.         if (not (cSystem = "Macintosh" and cVersion >= 2400))
  552.         {
  553.             print $format("\tInitialMemoryBlockSize    = %d", InitialMemoryBlock * 1024);
  554.             print $format("\tMemoryBlockSize           = %d", BlockSize * 1024);
  555.             print $format("\tMemoryBlockTotal          = %d", BlockCount);
  556.         }
  557.     }
  558.     print "";
  559.  
  560.     if(SetVar = "SAVE")
  561.     {
  562.         if(is_open=0)
  563.         {
  564.             print $format("\tThe Master database is not open so the values");
  565.             print $format("\tof the system variables can not be saved.");
  566.             print $format("\tYou need SA privilege to open the Master database.");
  567.             print "";
  568.             return;
  569.         }
  570.  
  571.         /* ConnectionTotal */
  572.         select    value
  573.         from    sysvariables
  574.         where    id = (select id from SysObjects where Name = "ConnectionTotal")
  575.         into tmp for extract;
  576.  
  577.         if($rows(tmp) == 1)
  578.         {
  579.             fetch first of tmp;
  580.  
  581.             if(Sessions > tmp->value)
  582.             {
  583.                 print $format("\tThe values can not be saved because the calculation is based on");
  584.                 print $format("\t%d sessions but the DataServer has a limit of %d sessions.", Sessions, int tmp->value);
  585.                 print "";
  586.                 return;
  587.             }
  588.         }
  589.         print $format("\tSaving the system variables...");
  590.         SET VARIABLE ConnectionLimit        = Sessions;
  591.         SET VARIABLE CacheSize                = CacheMemory/2 * 1024;
  592.         SET VARIABLE VirtualCacheSize        = CacheMemory/2 * 1024;
  593.         SET VARIABLE TransactionLimit        = TransactionLimit + 1;
  594.         SET VARIABLE SystemFileLimit        = SystemFiles;
  595.         if (cSystem = "Macintosh" and cVersion >= 2400)
  596.         {
  597.             SET VARIABLE InitialMemoryBlockSize    = $null;
  598.             SET VARIABLE MemoryBlockTotal        = $null;
  599.             SET VARIABLE MemoryBlockSize        = $null;
  600.         }
  601.         else
  602.         {
  603.             SET VARIABLE InitialMemoryBlockSize    = InitialMemoryBlock * 1024;
  604.             SET VARIABLE MemoryBlockTotal        = BlockCount;
  605.             SET VARIABLE MemoryBlockSize        = BlockSize * 1024;
  606.         }
  607.         print $format("\tDone");
  608.         if(cSystem = "Macintosh")
  609.         {
  610.             print $format("\tCaution: Set the 'Minimum size' in 'Memory Requirements' of the");
  611.             print $format("\t Server application with the finder's 'Get info' to %d", TotalMemory);
  612.             print "";
  613.         }
  614.         config(5);
  615.         close database mem_set;
  616.     }
  617. }
  618. end procedure config;
  619.  
  620. procedure setting()
  621. {
  622.     config(4,,,"show");
  623. }
  624. end procedure setting;
  625.  
  626. config(1);
  627.  
  628. /*
  629. execute file "config";
  630. go
  631. */
  632.